package com.yx.musicplayer.ui.activity;

import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.widget.DrawerLayout;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;

import com.yx.baselibrary.permission.PermissionHandler;
import com.yx.baselibrary.utils.DoubleClickExitUtil;
import com.yx.baselibrary.utils.IntentUtil;
import com.yx.baselibrary.utils.PermissionHandlerUtil;
import com.yx.baselibrary.widget.CommonBarView;
import com.yx.baselibrary.widget.TitleBarView;
import com.yx.musicplayer.R;
import com.yx.musicplayer.ui.base.BaseActivity;

import butterknife.BindView;

/**
 * @ClassName MainActivity
 * @Description 主页面
 * Created by yx on 2017/10/31 0031.
 */

public class MainActivity extends BaseActivity {
    DoubleClickExitUtil doubleClickExitUtil;
    @BindView(R.id.titleBar)
    TitleBarView titleBar;

    @BindView(R.id.nav_view)
    NavigationView navView;
    @BindView(R.id.drawerLayout)
    DrawerLayout drawerLayout;
    @BindView(R.id.local_music)
    CommonBarView local_music;


    @Override
    public void before(Bundle savedInstanceState) {

    }

    @Override
    public void initViewAndEvent() {
        showQuickControl(true);

        PermissionHandlerUtil.requestReadAndWriteSDPermission(this, new PermissionHandler() {
            @Override
            public void onGranted() {

            }
        });

        doubleClickExitUtil = new DoubleClickExitUtil(this);
        titleBar.setOnLeftIvClickListener(new TitleBarView.OnLeftIvClickListener() {
            @Override
            public void leftIvClick() {
                drawerLayout.openDrawer(Gravity.LEFT);
            }
        });


        local_music.setOnItemClickListener(new CommonBarView.OnItemClickListener() {
            @Override
            public void onItemClick(View view) {
                IntentUtil.readyGo(MainActivity.this, LocalMusicActivity.class);
            }
        });

    }

    @Override
    public int getContentViewLayoutID() {
        return R.layout.activity_main;
    }


    @Override
    public View getLoadingTargetView() {
        return null;
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return doubleClickExitUtil.onKeyDown(keyCode, event);
    }


}
